﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title></title>
</head>
<body>
    <script type="text/javascript" src="../js/jquery-2.2.3.min.js"></script>
    <script>
        function upload() {
            var formData = new FormData($("#uploadForm")[0])  //创建一个forData
            formData.append('img', $('#pic_img')[0].files[0]) //把file添加进去  name命名为img
            $.ajax({
                url: "http://localhost:50364/api/Admin/Goods/AddPic",
                data: formData,
                type: "POST",
                async: false,
                cache: false,
                contentType: false,
                processData: false,
                success: function (data) {
                   alert("success")
                },
                error: function () {
                    //失败
                }
            })
        }
    </script>
    <form enctype="multipart/form-data" id="uploadForm">
        <input type='file' name='xxx' id='pic_img'>
        <input type='button' onclick='upload()' value='点击上传'>
    </form>
</body>
</html>